package com.laozhao.deliveryManager.model.entity;

import java.math.BigDecimal;
import java.util.LinkedList;
import java.util.List;

import com.laozhao.deliveryManager.exception.NumberTooBigException;
import com.laozhao.deliveryManager.model.AbstractModel;
import com.laozhao.dreamframe.model.DreamDBColumn;
import com.laozhao.dreamframe.view.DreamTableModeMeta;
import com.laozhao.dreamframe.view.DreamUIColumn;

public class TransDeliveryDetail extends AbstractModel implements DreamTableModeMeta{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4676639492179957915L;
	
	@DreamDBColumn( dbColunName = "GOODS_ID")
	public MstGoods goods;
	
	@DreamUIColumn( uiColumnHide = false , uiColumnIndex = 1 , uiColumnTitle = "GoodsCode", columnEditable = true)
	@DreamDBColumn( dbColunName = "GOODS_CODE")
	public String goodsCode;
	
	@DreamUIColumn( uiColumnHide = false , uiColumnIndex = 2 , uiColumnTitle = "GoodsNameSize", columnEditable = true)
	@DreamDBColumn( dbColunName = "GOODS_NAME_SIZE")
	public String goodsNameSize;
	
	@DreamUIColumn( uiColumnHide = false , uiColumnIndex = 3 , uiColumnTitle = "GoodsUnit", columnEditable = true)
	@DreamDBColumn( dbColunName = "GOODS_UNIT")
	public String goodsUnit;
	
	@DreamUIColumn( uiColumnHide = false , uiColumnIndex = 4 , uiColumnTitle = "Price", columnEditable = true)
	@DreamDBColumn( dbColunName = "PRICE" )
	public Float price;
	
	@DreamUIColumn( uiColumnHide = false , uiColumnIndex = 5 , uiColumnTitle = "Qyantity", columnEditable = true)
	@DreamDBColumn( dbColunName = "QUANTITY")
	public Float quantity;
	
	@DreamUIColumn( uiColumnHide = false , uiColumnIndex = 6 , uiColumnTitle = "Amount", columnEditable = false)
	@DreamDBColumn( dbColunName = "AMOUNT")
	public Float amount;
	
	public MstGoods getGoods() {
		return goods;
	}
	public void setGoods(MstGoods goods) {
		this.goods = goods;
	}
	public String getGoodsCode() {
		return goodsCode;
	}
	public void setGoodsCode(String goodsCode) {
		this.goodsCode = goodsCode;
	}
	public String getGoodsNameSize() {
		return goodsNameSize;
	}
	public void setGoodsNameSize(String goodsNameSize) {
		this.goodsNameSize = goodsNameSize;
	}
	public String getGoodsUnit() {
		return goodsUnit;
	}
	public void setGoodsUnit(String goodsUnit) {
		this.goodsUnit = goodsUnit;
	}
	public Float getPrice() {
		return price;
	}
	public void setPrice(Float price) {
		this.price = price;
	}
	public Float getAmount() {
		return amount;
	}
	public void setAmount(Float amount) {
		this.amount = amount;
	}
	
	public List<String> getViewAmount(int precision, int scale) throws NumberTooBigException{
		if (precision < scale) {
			throw new NumberFormatException();
		}
		LinkedList<String> reList = new LinkedList<String>();
		if (amount.isNaN()) {
			for (int i = 0; i < precision; i--) {
//				if (i < ) {
//					
//				}
				reList.add("0");
			}
		}else {
			String amountStr = BigDecimal.valueOf(amount).setScale(scale,BigDecimal.ROUND_HALF_UP).toPlainString();
			amountStr.replaceAll(".", "");
			if (amountStr.length()<= precision) {
				
//				reList.add(amount.t)
			}else {
				throw new NumberTooBigException();
			}
			
		}
		
		return reList;
	}
	public Float getQuantity() {
		return quantity;
	}
	public void setQuantity(Float quantity) {
		this.quantity = quantity;
	}
	
	@Override
	public void setStatus(Status status) {
				
	}
	@Override
	public Status getStatus() {
		return null;
	}
}
